package com.golang.api.repository;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.golang.api.domain.Tag;
import com.golang.api.dto.request.TagSearchDto;
import com.golang.api.mapper.TagMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;


@Repository
public class TagRepository {

    @Resource
    TagMapper tagMapper;


    public List<Tag> queryTag(TagSearchDto query) {
        LambdaQueryWrapper<Tag> queryWrapper = new LambdaQueryWrapper<>();
        //分类
        queryWrapper.like(Objects.nonNull(query.getTagName()), Tag::getTagName, query.getTagName());
        //开始时间
        queryWrapper.eq(Objects.nonNull(query.getTagType()), Tag::getTagType, query.getTagType());


        return tagMapper.selectList(queryWrapper);
    }



    public int insertTagInfo(Tag entity) {
        return tagMapper.insert(entity);
    }

}
